package br.edu.oxente.buzz.entity;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Nigini A. Oliveira - ensino@nigini.com.br
 */
public class Post {
	private User user;
	private String text;
	private List<Comment> comments;

	public Post( User user, String text ) {
		if (user == null || text == null) throw new IllegalArgumentException("Nor user, nor text can be NULL.");
		this.user = user;
		this.text = text;
		this.comments = new LinkedList<Comment>();
	}

	public String getText() {
		return this.text;
	}

	public List<Comment> getComments() {
		return this.comments;
	}

	public void insertComment( Comment comment ) {
		this.comments.add(comment);
	}

	@Override
	public boolean equals( Object o ) {
		if( o instanceof Post ) {
			Post p = (Post) o;
			boolean equal = user.equals( p.user );
			equal &= text.equals( p.text );
			return equal;
		}
		return false;
	}
}
